<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packagePrefix}.infrastructure.mapper.${domainObjectName}Mapper">

    <!-- 结果映射 -->
    <resultMap id="BaseResultMap" type="${packagePrefix}.infrastructure.dataobject.${domainObjectName}DO">
        <id column="id" property="id" />
<#list fields as field>
        <result column="${field.columnName}" property="${field.name}" />
</#list>
    </resultMap>

    <!-- 通用查询列 -->
    <sql id="Base_Column_List">
        id, <#list fields as field>${field.columnName}<#if field_has_next>, </#if></#list>
    </sql>

    <!-- 根据ID查询 -->
    <select id="selectById" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM ${tableName}
        WHERE id = <#noparse>#{id,jdbcType=BIGINT}</#noparse>
    </select>

    <!-- 根据ID删除 -->
    <delete id="deleteById">
        DELETE FROM ${tableName}
        WHERE id = <#noparse>#{id,jdbcType=BIGINT}</#noparse>
    </delete>
</mapper> 